package com.wzh.yebServe.controller;

import com.wzh.yebServe.pojo.Department;
import com.wzh.yebServe.pojo.ResultBean;
import com.wzh.yebServe.service.IDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author wzh
 * @create 2022/11/17 20:01
 * @Description:
 */

@RestController
@Api(tags = "DepartmentController 部门接口")
@RequestMapping("/system/basic/department")
public class DepartmentController {
    @Autowired
    private IDepartmentService iDepartmentService;

    @ApiOperation(value = "获取所有部门")
    @GetMapping("/")
    public List<Department> getAllDepartments(){
     return iDepartmentService.getAllDepartments();
    }

    @ApiOperation(value = "添加一个部门")
    @PostMapping("/")
    public ResultBean addDep(@RequestBody Department department){
       return iDepartmentService.addDep(department);
    }


    @ApiOperation(value = "删除一个部门")
    @DeleteMapping("/{id}")
    public ResultBean deleteDepartment(@PathVariable Integer id){
        return iDepartmentService.deleteDepartment(id);
    }


}
